package com.test.demoapp.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.Window
import androidx.appcompat.app.AppCompatActivity


abstract class BaseActivity : AppCompatActivity() {

    abstract fun initUI(savedInstanceState: Bundle?)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        if (needToolBar()) {
            supportRequestWindowFeature(Window.FEATURE_NO_TITLE)
            setContentView(setLayoutResId())
        } else {
            setContentView(setLayoutResId())
        }
        initUI(savedInstanceState)
    }

    open fun needToolBar(): Boolean {
        return false;
    }

    abstract fun setLayoutResId(): Int

    fun makeView(resId: Int): View {
        var inflater = LayoutInflater.from(this);
        return inflater.inflate(resId, null, false);
    }

}
